package org.groupg.practice.guava.Range;

import com.google.common.collect.BoundType;
import com.google.common.collect.Range;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.math.BigDecimal;

public class RangePractice {
    private static final Logger log = LoggerFactory.getLogger(RangePractice.class);

    public static void main(String[] args) {

        // > 10
        Range<Double> range1 = Range.greaterThan(10.0); // 大于10的区间，不包含10
        Range<Double> range2 = Range.atLeast(10.0);     // 大于等于10的区间，包含10
        Range<Double> range3 = Range.lessThan(5.0);     // 小于5的区间，不包含5
        Range<Double> range4 = Range.atMost(5.0);       // 小于等于5的区间，包含5

        Range<BigDecimal> range5 = Range.range(BigDecimal.valueOf(0L), BoundType.CLOSED, BigDecimal.valueOf(10L), BoundType.OPEN); // 等同于closedOpen(1, 5)

        log.debug("{}", (range1.contains(12.0)));
    }
}
